styleproperty: Call style properties init function in more places
authorBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 21:06:17 +0000 (22:06 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 21:08:48 +0000 (22:08 +0100)
In particular, call it when querying properties by id. This is necessary
for make check to not die.

gtk/gtkcssstyleproperty.c
gtk/gtkstyleproperty.c
gtk/gtkstylepropertyprivate.h

index 70d88a721a7072aff8d70aaf774bed907af80288..d547ce31f3f6a5953906222c5e3e59e3ec2ab657 100644 (file)
@@ -287,6 +287,12 @@ _gtk_css_style_property_get_n_properties (void)
   GtkCssStylePropertyClass *klass;
 
   klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
+  if (G_UNLIKELY (klass == NULL))
+    {
+      _gtk_style_property_init_properties ();
+      klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
+      g_assert (klass);
+    }
 
   return klass->style_properties->len;
 }
@@ -307,6 +313,13 @@ _gtk_css_style_property_lookup_by_id (guint id)
   GtkCssStylePropertyClass *klass;
 
   klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
+  if (G_UNLIKELY (klass == NULL))
+    {
+      _gtk_style_property_init_properties ();
+      klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
+      g_assert (klass);
+    }
+  g_return_val_if_fail (id < klass->style_properties->len, NULL);
 
   return g_ptr_array_index (klass->style_properties, id);
 }
index a8197842d78bd55a3138fc6db99573ba3f244bfa..be86c97e5aef045c20a738d8fd90ce11e0ae67a9 100644 (file)
@@ -226,8 +226,8 @@ _gtk_style_property_query (GtkStyleProperty        *property,
   klass->query (property, props, state, value);
 }
 
-static void
-gtk_style_property_init_properties (void)
+void
+_gtk_style_property_init_properties (void)
 {
   static gboolean initialized = FALSE;
 
@@ -258,7 +258,7 @@ _gtk_style_property_lookup (const char *name)
 
   g_return_val_if_fail (name != NULL, NULL);
 
-  gtk_style_property_init_properties ();
+  _gtk_style_property_init_properties ();
 
   klass = g_type_class_peek (GTK_TYPE_STYLE_PROPERTY);
 
index 7e97b70fb0af3a845efca73ae75ca66e2c519a35..78cef8c4b102737d63bcbdb5e7b419ff373e831a 100644 (file)
@@ -78,6 +78,8 @@ struct _GtkStylePropertyClass
 
 GType               _gtk_style_property_get_type             (void) G_GNUC_CONST;
 
+void                _gtk_style_property_init_properties      (void);
+
 GtkStyleProperty *       _gtk_style_property_lookup        (const char             *name);
 
 const char *             _gtk_style_property_get_name      (GtkStyleProperty       *property);